#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    cout << "creating mainview"<<endl;
    ui->setupUi(this);
   // pm = NULL;
    cout << "create the oglview"<<endl;
    gl = new GLWidget(this,0);
    Lfps = new QLabel(this);

    cout << "initialising a 10ms timer"<<endl;
    timer = new QTimer();
    timer->start(1000/60);

            createView();
    cout << "mainwindowview finished" << endl;

}

MainWindow::~MainWindow()
{
    delete ui;
    delete gl;
    delete pm;

}

void MainWindow::createView()
{
    Lfps->move(1445,20);
    this->resize(1500,940);
    gl->resizeGL(1440,940);

    gl->resize(1440,940);


    cout << "connecting fps timer" << endl;
    connect(timer,SIGNAL(timeout()),this,SLOT(refreshFPS()));

}

void MainWindow::refreshFPS()
{
    Lfps->setText(tr("fps: ")+QString::number(gl->getFPS()));
    gl->renderParticles();
}
